package com.itany.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itany.dao.MessageDao;
import com.itany.entity.Message;
import com.itany.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * Author:yaozhiyuan0117@163.com
 * Time:2019/12/20 19:44
 * Describe:
 * version:1.0
 */

@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class MessageServiceImpl implements MessageService {

    @Autowired
    MessageDao messageDao;

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public PageInfo<Message> findByPage(Integer page, Integer rows, HashMap map) {
        PageHelper.startPage(page, rows);
        List<Message> messages = messageDao.selectAll(map);
        PageInfo<Message> info = new PageInfo<>(messages);
        return info;
    }
}
